package com.weifangfirecontrolformal.weifangfirecontrolformal.web.web.check.hiddendanger;

import cn.hutool.json.JSONObject;
import com.weifangfirecontrolformal.weifangfirecontrolformal.common.base.BaseController;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.annotaion.Action;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.annotaion.At;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.model.RespEntity;
import com.weifangfirecontrolformal.weifangfirecontrolformal.web.service.check.hiddendanger.HiddendangerService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * 隐患控制器
 */
@Action
@RequestMapping(value="check/hiddendanger")
public class HiddendangerController extends BaseController {
    @Resource
    public HiddendangerService hiddendangerService;

    /**
     * 隐患列表
     * @param
     * page	第几页
     * businessId	单位id：如果是机构用户登录需要传,如果是单位用户自己取
     * findtime	发现时间
     * grade	隐患等级：对应字典表
     * state	状态：对应字典表
     * limit	每页多少条
     * rfid	RFID码	是
     * @return
     */
    @At(value = "hiddendangerListPage", method = RequestMethod.GET, param = { "page","limit"})
    public RespEntity hiddendangerListPage(@RequestBody(required = false) JSONObject jsonParam) {
        return hiddendangerService.hiddendangerListPage(jsonParam);
    }

    /**
     * 隐患详情
     * @param
     * id	隐患id
     * haveHiddendanger	现在还有隐患，前端会传1
     * rfid	RFID码
     * @return
     */
    @At(value = "detail", method = RequestMethod.GET)
    public RespEntity detail(@RequestBody(required = false) JSONObject jsonParam) {
        return hiddendangerService.detail(jsonParam);
    }

    /**
     * 隐患添加
     * @param
     * rfid	RFID码
     * des	隐患描述
     * grade	隐患等级：对应字典表
     * state	状态：对应字典表
     * @return
     */
    @At(value = "add", method = RequestMethod.POST, param = { "rfid","grade","state" })
    public RespEntity add(@RequestBody(required = false) JSONObject jsonParam) {
        return hiddendangerService.add(jsonParam);
    }

    /**
     * 隐患修改
     * @param
     * rfid	RFID码
     * grade	隐患等级：对应字典表
     * id	隐患id
     * state	状态：对应字典表
     * @return
     */
    @At(value = "update", method = RequestMethod.POST, param = { "grade","state" })
    public RespEntity update(@RequestBody(required = false) JSONObject jsonParam) {
        return hiddendangerService.update(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 监管账号隐患新增、更新
     * @Date Created in 16:16 2023/1/30
     * @Param [jsonParam]
     */

    @At(value = "orgHiddenDangerAddOrUpdate", method = RequestMethod.POST)
    public RespEntity orgHiddenDangerAddOrUpdate(@RequestBody(required = false) JSONObject jsonParam) {
        return hiddendangerService.orgHiddenDangerAddOrUpdate(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 监管账号隐患详情
     * @Date Created in 16:16 2023/1/30
     * @Param [jsonParam]
     */

    @At(value = "orgHiddenDangerDetails", method = RequestMethod.GET)
    public RespEntity orgHiddenDangerDetails(@RequestBody(required = false) JSONObject jsonParam) {
        return hiddendangerService.orgHiddenDangerDetails(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 监管账号隐患删除
     * @Date Created in 16:17 2023/1/30
     * @Param [jsonParam]
     */

    @At(value = "orgHiddenDangerDel", method = RequestMethod.POST)
    public RespEntity orgHiddenDangerDel(@RequestBody(required = false) JSONObject jsonParam) {
        return hiddendangerService.orgHiddenDangerDel(jsonParam);
    }
}
